﻿<Window x:Class="Cjc.ChromiumBrowserDemo.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:cjc="clr-namespace:Cjc.ChromiumBrowser;assembly=Cjc.ChromiumBrowser"
		xmlns:properties="clr-namespace:Cjc.ChromiumBrowserDemo.Properties"
		xmlns:effect="clr-namespace:ShaderEffectLibrary"
		xmlns:local="clr-namespace:Cjc.ChromiumBrowserDemo"
		Title="WPF Chromium Browser" Name="window"
		Width="900" Height="600" Background="#E0E0E0">

    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="boolVisibility"/>
    </Window.Resources>

    <Grid Name="grid">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <cjc:WebBrowser Name="browser" Grid.Row="1" Status="browser_Status" ReceiveTitle="browser_ReceiveTitle"
						RenderTransformOrigin="0.5,0.5" TabIndex="2" Focusable="True"
						Effect="{Binding SelectedItem.Value, ElementName=effects}">
            <cjc:WebBrowser.LayoutTransform>
                <TransformGroup>
                    <RotateTransform Angle="{Binding Value, ElementName=angle}"/>
                    <ScaleTransform ScaleX="{Binding Value, ElementName=scale}" ScaleY="{Binding Value, ElementName=scale}"/>
                </TransformGroup>
            </cjc:WebBrowser.LayoutTransform>
        </cjc:WebBrowser>

        <Grid Name="header" Grid.Row="0" VerticalAlignment="Top" Background="#80FFFFFF" Focusable="False">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Name="back" Content="&lt;" VerticalAlignment="Center"
					Margin="5,0,0,0" Click="back_Click"/>
            <Button Grid.Column="1" Name="forward" Content="&gt;" VerticalAlignment="Center"
					Margin="2,0,0,0" Click="forward_Click"/>
            <TextBlock Grid.Column="2" Text="Address" Margin="5" VerticalAlignment="Center" Focusable="False"/>
            <TextBox Name="address" Grid.Column="3" Margin="0,5,0,5" VerticalAlignment="Center"
					 Text="{Binding Source, Mode=OneWay, ElementName=browser}" TabIndex="0" />
            <Control Name="loading" Grid.Column="4" Template="{StaticResource loadingAnimation}" Foreground="Green"
					 Width="20" Margin="5,5,0,5" Visibility="Collapsed" />
            <Button Grid.Column="5" Content="Go" Margin="5,5,0,5" Click="Button_Click" VerticalAlignment="Center"
					TabIndex="1" Focusable="True" IsDefault="{Binding IsKeyboardFocused, ElementName=address}"/>
            <Button Grid.Column="6" Content="Set default" Margin="5" Click="Default_Click" VerticalAlignment="Center"
					TabIndex="1" Focusable="True"/>
        </Grid>

		<Grid Grid.Row="1">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="0.5*"/>
				<ColumnDefinition Width="0.5*"/>
			</Grid.ColumnDefinitions>
			<ListBox Name="status" Grid.Column="0" Foreground="Red" BorderThickness="0"
				 Visibility="{Binding IsChecked, ElementName=debug, Converter={StaticResource boolVisibility}}"
				 Padding="5" Background="#D0F8F8F8" HorizontalAlignment="Left" VerticalAlignment="Top"/>
			<ScrollViewer Grid.Column="1" BorderThickness="0" Padding="5" Background="#D0F8F8F8" VerticalAlignment="Top"
						  Visibility="{Binding IsChecked, ElementName=console, Converter={StaticResource boolVisibility}}">
				<StackPanel>
					<ListBox ItemsSource="{Binding Console, ElementName=window}" BorderThickness="0" Background="Transparent"/>
					<Grid Margin="5">
						<Grid.ColumnDefinitions>
							<ColumnDefinition/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<TextBox Grid.Column="0" Name="command" />
						<Button Name="execute" Grid.Column="1" Margin="5,0,0,0" IsDefault="True" Click="execute_Click">E_xecute</Button>
					</Grid>
				</StackPanel>
			</ScrollViewer>
		</Grid>

		<Grid Grid.Row="2" Background="#80FFFFFF">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="Auto" />
			</Grid.ColumnDefinitions>
			<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,5,0,5">
				<TextBlock Text="Debug" VerticalAlignment="Center"/>
				<CheckBox Name="debug" VerticalAlignment="Center" IsChecked="False" Margin="5,0,0,0"/>
			</StackPanel>
			<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="10,5,0,5">
				<TextBlock Text="Console" VerticalAlignment="Center"/>
				<CheckBox Name="console" VerticalAlignment="Center" IsChecked="False" Margin="5,0,0,0"/>
			</StackPanel>
			<TextBlock Grid.Column="2" VerticalAlignment="Center" Margin="10,5,0,5" Text="Rotate"/>
			<Slider Grid.Column="3" Name="angle" Minimum="-180" Maximum="180" VerticalAlignment="Center"
				Focusable="False" Margin="5,5,0,5" />
			<TextBlock Grid.Column="4" VerticalAlignment="Center" Margin="10,5,0,5" Text="Scale"/>
			<Slider Grid.Column="5" Name="scale" Minimum="0.5" Maximum="3" VerticalAlignment="Center" Value="1" 
				Focusable="False" Margin="5,5,0,5" />
			<ComboBox Grid.Column="6" VerticalAlignment="Center" Name="effects" Margin="10,5,0,5" SelectedIndex="0"
					  ItemsSource="{Binding Effects, ElementName=window}" DisplayMemberPath="Key" SelectedValuePath="Value"/>
			<Button Grid.Column="7" Name="openTransparent" Content="New window" Margin="5,5,0,5"
					Click="openTransparent_Click" VerticalAlignment="Center"/>
			<Button Grid.Column="8" Name="zoomIn" Content="+" Margin="5,5,0,5"
					Click="zoomIn_Click" VerticalAlignment="Center"/>
			<Button Grid.Column="9" Name="zoomOut" Content="-" Margin="5"
					Click="zoomOut_Click" VerticalAlignment="Center"/>
		</Grid>

	</Grid>
</Window>